<%@page import="java.util.ResourceBundle"%>
<%@page import="jp.co.hcs.attendancemanagement.StrutsMessageConstants"%>
<%@page import="jp.co.hcs.attendancemanagement.AMResourceKeyConstants"%>
<%@page import="jp.co.hcs.attendancemanagement.AMResourceManager"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="/WEB-INF/tld/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/tld/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tld/struts-logic.tld" prefix="logic"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String deleteMessage = AMResourceManager.getMessage(AMResourceKeyConstants.MSG_DELETEMESSAGE_SCREEN5041);
%>
<html>
<head>
<title><bean:message key="menu.item.inputTableB"/></title>
<link rel="stylesheet" href="<c:url value="/css/inputtableb/inputtableb.css" />" type="text/css">
</head>
<script language="JavaScript">
  var isTimeValueChanged = false;
  var isProjectNumberWorkCodeChanged = false;
	var projectChecked = false;
	var seriCheck = false;
	var oldTotalTimeInMonth = 0;
	var oldProjectNameValues = new Array();
  var oldWorkNameValues = new Array();
    $(document).ready(function(){
    	
    	//div contain div y-fake-scroll
    	var YtableEmulator = document.getElementById('y-table-emulator');
    	//div contain div x-fake-scroll
    	var XtableEmulator = document.getElementById('x-table-emulator');
    	//main table that will be scroll
    	var table = document.getElementById('tableSchedule');

    	YtableEmulator.style.height = table.clientHeight == 0 ? "100px" : table.clientHeight + "px";

    	XtableEmulator.style.width = table.clientWidth + "px";

    	var scrollablePanel = document.getElementById('scroll');
    	var leftScrollablePanel = document.getElementById('div-left-body');
    	//header container is div contain table header
    	var headerContainer = document.getElementById('header-container');
    	//footer container is div contain table footer
    	var footerContainer = document.getElementById('footer-container');
    	var YfakeScrollablePanel = document.getElementById('y-fake-scroll');
    	var XfakeScrollablePanel = document.getElementById('x-fake-scroll');

    	//alert(scrollablePanel.clientHeight);
    	YfakeScrollablePanel.style.top = headerContainer.clientHeight == 0 ? "34px" : headerContainer.clientHeight + "px";
    	scrollablePanel.onscroll = function (e) {
    	  	XfakeScrollablePanel.scrollTop = scrollablePanel.scrollTop;
    	};
    	YfakeScrollablePanel.onscroll = function (e) {
    	  	scrollablePanel.scrollTop = YfakeScrollablePanel.scrollTop;
    		leftScrollablePanel.scrollTop = YfakeScrollablePanel.scrollTop;
    	};
    	XfakeScrollablePanel.onscroll = function (e) {
    	  	scrollablePanel.scrollLeft = XfakeScrollablePanel.scrollLeft;
    		headerContainer.scrollLeft = XfakeScrollablePanel.scrollLeft;
    		footerContainer.scrollLeft = XfakeScrollablePanel.scrollLeft;
    	};
    	
    	scrollablePanel.onscroll = function (e) {
    		    XfakeScrollablePanel.scrollLeft = scrollablePanel.scrollLeft;
            headerContainer.scrollLeft = scrollablePanel.scrollLeft;
            footerContainer.scrollLeft = scrollablePanel.scrollLeft;
          };
    	
    	var couter = 0;
    	$("#formProjectInfo").submit(function()
    	{
    		couter++;
    	if ( couter > 1 ) { return false; }
    	});
    	
    	//var tColumnCounttemp = $('table#tblprojectEffortInfro tr:eq('+0+') td').length;
    	//alert(tColumnCounttemp);
    	//for(var col = 0; col < tColumnCounttemp; col++){
    	//	alert($('table#tblprojectEffortInfro tr:eq('+0+') td').eq(col).width());
    	//}
    	$('#dateInline').datepick({
    		dateFormat: "yyyymm",
    		altField:'#txtYear',
    		onSelect: selectDateTimeByLeftDateInlinePicker
    		});
    	
    	$('#txtYear').datepick({
    		showOnFocus:false,
    		dateFormat: "yyyymm",
    		altField:'#hiddenDatePick',
    		onSelect: selectDateTime
    		});
    	$('#datepickButton').click(function() {
      		$('#txtYear').datepick('show');
		});
 
    	var tRowCount = $('table#tableSchedule tr').length;
    	var tColumnCount = $('table#tableSchedule tr:eq('+2+') td').length;
    	
    	for(var row = 0; row < tRowCount; row++){
    		oldProjectNameValues[row] = $('table#tblprojectEffortInfro tr:eq('+(row)+') td').eq(4).find('label').text();
    		oldWorkNameValues[row] = $('table#tblprojectEffortInfro tr:eq('+(row)+') td').eq(7).find('label').text();
    		$('table#tblprojectEffortInfro tr:eq('+(row)+') td').eq(8).find('label').text(calculateTotalRow(0, row));
    	}
    	$('#totalTimeInMonth').text(setTotalTimeInMonth($('table#tblprojectEffortInfro tr').length));
    	 oldTotalTimeInMonth = $('#totalTimeInMonth').text();
    	for(var col = 0; col < tColumnCount; col++){
    		$('table#table-footer tr:eq('+0+') td').eq(col).find('label').text(setTotalTimeByColumn(col));
    	}
    	
    	$('.cellSchedule').focusout(function () {
    		//$('#btnSave').removeAttr('disabled');
    		//checkValdation(this);
    		 var colIndex = $(this).parent().parent().children().index($(this).parent());
    		 var rowIndex = $(this).parent().parent().parent().children().index($(this).parent().parent());
        	if(checkValdation(this)){
        		//calculateTotalRow(colIndex, rowIndex);
        		$('table#tblprojectEffortInfro tr:eq('+(rowIndex)+') td').eq(8).find('label').text(calculateTotalRow(colIndex, rowIndex));
        		$('table#table-footer tr:eq('+(0)+') td').eq(colIndex).find('label').text(setTotalTimeByColumn(colIndex));
        		var rowCount = $('#tblprojectEffortInfro tr').length;
        		$('#totalTimeInMonth').text(setTotalTimeInMonth(rowCount));
        		if(oldTotalTimeInMonth != $('#totalTimeInMonth').text()){
        			$('#btnSave').removeAttr('disabled');
        			$('#btnExport').attr('disabled', '');
              $('#btnDelete').attr('disabled', '');
              isTimeValueChanged = true;
        		}
        		else{
        			isTimeValueChanged = false; 
        			if(!isProjectNumberWorkCodeChanged){
        				  $('#btnSave').attr('disabled', '');
        	        $('#btnExport').removeAttr('disabled');
        	        $('#btnDelete').removeAttr('disabled');
        			}
        		}
        	}
        });
    	
    	$('.projectCodeCheck').focusout(function () {
    		checkProjectCodeAndSeri(this);
    	});
    	
		$('.projectSeriCheck').focusout(function () {
			checkProjectCodeAndSeri(this);
    	});
		
		$('#txtYear').focusout(function () {
			var currentYear = parseInt((new Date).getFullYear());
	    	var currentMonth = parseInt((new Date).getMonth()+1);
			if($('#txtYear').val() == null || 
					$('#txtYear').val().length != 4 || 
  					!isNumeric($('#txtYear').val())){
  				alert("<bean:message key="Alarm.W1014.error"/>");
  				$('#txtYear').focus();
			}
			else if($('#txtMonth').val().length != 2 ||
  				!isNumeric($('#txtMonth').val()) ||  month >= 13){
				return;
			}
			else if($('#txtYear').val() != null && $('#txtYear').val().length != 0){
	    		var year = $('#txtYear').val();
	    		var month;
	    		if($('#txtMonth').val()!= null){
	    			month = $('#txtMonth').val();
	    			if(currentYear < year || (year < currentYear - 5)){
		    			$('#txtYear').val(currentYear);
		    			alert("<bean:message key="Alarm.W1014.error"/>");
		    			$('#txtYear').focus();
		    		}
	    			else if (((currentMonth < month) && (currentYear == year)) || ((year == currentYear - 5) && (month < currentMonth))){
	    				$('#txtYear').val(currentYear);
		    			alert("<bean:message key="Alarm.W1014.error"/>");
		    			$('#txtMonth').focus();
	    			}
	    		}
	    	}
    	});
		
		$('#txtMonth').focusout(function () {
			var currentYear = parseInt((new Date).getFullYear());
	    	var currentMonth = parseInt((new Date).getMonth()+1);
	    	
			if($('#txtMonth').val().length != 2 ||
  				!isNumeric($('#txtMonth').val()) || $('#txtMonth').val() >= 13){
  				alert("<bean:message key="Alarm.W1014.error"/>");
  				$('#txtMonth').focus();
			}
			else if($('#txtYear').val() == null || 
					$('#txtYear').val().length != 4 || 
  					!isNumeric($('#txtYear').val())){
				return;
			}
			else if($('#txtYear').val() != null && $('#txtYear').val().length != 0){
	    		var year = $('#txtYear').val();
	    		var month = $('#txtMonth').val();
    			if(currentYear < year || (year < currentYear - 5)){
	    			$('#txtYear').val(currentYear);
	    			alert("<bean:message key="Alarm.W1014.error"/>");
	    			$('#txtYear').focus();
	    		}
    			else if (((currentMonth < month) && (currentYear == year)) || ((year == currentYear - 5) && (month < currentMonth))){
    				$('#txtYear').val(currentYear);
	    			alert("<bean:message key="Alarm.W1014.error"/>");
	    			$('#txtMonth').focus();
    			}
	    	} 
  				
    	});
    	
    	 $('#btnDelete').click(function(){
 			if($(".case:checked").length <= 0){
 				alert("<bean:message key='Alarm.W1032.error'/>");
 				return false;
 			}
 			return beforeDelete();
 		});
    	 $('#btnShow').click(function(){
  			if($('#txtYear').val().length = 0 || $('#txtMonth').val().length <= 0){
  				alert("<bean:message key='Alarm.W1101.error'/>");
  				return false;
  			}
  			
  			if($('#txtYear').val().length != 4 || 
  					$('#txtMonth').val().length != 2 ||
  					!isNumeric($('#txtYear').val()) ||
  					!isNumeric($('#txtMonth').val())){
  				alert("<bean:message key="Alarm.W1014.error"/>");
  				return false;
  			}
  		});
    	 
    });
    
    
    function checkWorkCode(inputWorkCodeControl) {
    	//convert fullsize to halfsize
    	
    	var trActived = $(inputWorkCodeControl).parent().parent();
    	var selectedRowIndex = $(trActived).parent().children().index($(trActived));
    	
    	inputWorkCodeControl.value = chkCode(inputWorkCodeControl.value);
    	var newWorkCodeValue = $(inputWorkCodeControl).val();
		if(inputWorkCodeControl.value.length == 0){
			$(trActived).find('label[id="workName"]').text("");
			$(trActived).find('input[id="hiddenWorkName"]').val("");
			return;
		}
		if(inputWorkCodeControl.value.length != 10){
			alert("<bean:message key='Alarm.W1098.error' arg0='Work Code '/>");
			$(trActived).find('label[id="workName"]').text("");
			$(trActived).find('input[id="hiddenWorkName"]').val("");
			//inputWorkCodeControl.focus();
		}
		else{
			$.getJSON("checkworkcode.do?workCode="+inputWorkCodeControl.value,
					function(data){
						//$(trActived).find('input[name*="workCode"]').val(data.workId);
						if(data != null){
							$(trActived).find('label[id="workName"]').text(data.workName);
							$(trActived).find('input[id="hiddenWorkName"]').val(data.workName);
						}
						else{
							$(trActived).find('label[id="workName"]').text("");
							$(trActived).find('input[id="hiddenWorkName"]').val("");
							alert("<bean:message key='Alarm.W1058.error' arg0='" + newWorkCodeValue +"'/>");
							//inputWorkCodeControl.focus();
						}
						
						 if( oldWorkNameValues[selectedRowIndex] != $(trActived).find('label[id="workName"]').text()){
				                $('#btnSave').removeAttr('disabled');
				                $('#btnExport').attr('disabled', '');
				                $('#btnDelete').attr('disabled', '');
				                isProjectNumberWorkCodeChanged = true;
				              }
				              else{
				            	  isProjectNumberWorkCodeChanged = false;
				            	  if(!isTimeValueChanged){
				            		  $('#btnSave').attr('disabled', '');
				                  $('#btnExport').removeAttr('disabled');
				                  $('#btnDelete').removeAttr('disabled');
				            	  }
				                
				              }
					});
		}
	}
	
    function checkProjectCodeAndSeri(inputProjectControl){
    	inputProjectControl.value = chkCode(inputProjectControl.value);
    	
    var projectNumber="";	
		var seri="";
		var projectCode="";
		var isprojectCheck = false;
		var isseriCheck = false;
		var trActived = $(inputProjectControl).parent().parent();
		if(inputProjectControl.name.indexOf("projectCode")!= -1){
			isprojectCheck = true;
			projectChecked = true;
			projectCode = inputProjectControl.value;
			var seriField = $(trActived).find('input[name*="seri"]');
			seri = chkCode(seriField.val());
			seriField.val(seri);
		}
		else if(inputProjectControl.name.indexOf("seri")!= -1){
			seri = inputProjectControl.value;
			isseriCheck = true;
			var prjCodeField = $(trActived).find('input[name*="projectCode"]');
			projectCode = chkCode(prjCodeField.val());
			prjCodeField.val(projectCode);
		}
		if((projectCode == "" || projectCode == null) && (seri == null || seri == "")){
			return;
		}
		
		if(projectCode.length != 6 || seri.length != 2){
			$(trActived).find('label[id="projectName"]').text("");
			$(trActived).find('input[id="hiddenProjectName"]').val("");
			alert("<bean:message key='Alarm.W1098.error' arg0='Project code or seri ' />");
			return;
		}
		else{
			projectNumber = projectCode + seri;
			
				$.getJSON("checkprojectcode.do?projectCode="+projectCode+"&seri="+seri,
						function(data){
							if(data != null){
								$(trActived).find('label[id="projectName"]').text(data.projectName);
								$(trActived).find('input[id="hiddenProjectName"]').val(data.projectName);
							}
							else{
								$(trActived).find('label[id="projectName"]').text("");
								$(trActived).find('input[id="hiddenProjectName"]').val("");
								if(isprojectCheck == true && seriCheck == true){
					    			return;
					    		}
							
								if(projectChecked == true && seriCheck == false  && isseriCheck == true){
									seriCheck = true;
									return;
								}
								alert("<bean:message key='Alarm.W1058.error' arg0='"+projectNumber+" '/>");
							}
							 var selectedRowIndex = $(inputProjectControl).parent().parent().parent().children().index($(inputProjectControl).parent().parent());
			         if( oldProjectNameValues[selectedRowIndex] != $(inputProjectControl).parent().parent().find('label[id="projectName"]').text()){
			              $('#btnSave').removeAttr('disabled');
			              $('#btnExport').attr('disabled', '');
			              $('#btnDelete').attr('disabled', '');
			              isProjectNumberWorkCodeChanged = true;
                }
                else{
                   isProjectNumberWorkCodeChanged = false;
                   if(!isTimeValueChanged){
                     $('#btnSave').attr('disabled', '');
                     $('#btnExport').removeAttr('disabled');
                     $('#btnDelete').removeAttr('disabled');
                   }
			         }
							
						});
		}
		
	}
	
    function selectDateTime(){
    	var currentYear = parseInt((new Date).getFullYear());
    	var currentMonth = parseInt((new Date).getMonth()+1);
    	if($('#txtYear').val() != null && $('#txtYear').val().length != 0){
    		var year = $('#txtYear').val().substring(0,4);
    		var month = $('#txtYear').val().substring(4,6);
    		if(currentYear < year || ((currentMonth < month) && (currentYear == year)) || (year < currentYear - 5) || ((year == currentYear - 5) && (month < currentMonth))){
    			$('#txtYear').val(currentYear);
    			alert("<bean:message key="Alarm.W1014.error"/>");
    			return;
    		}
    		$('#txtYear').val(year);
    		$('#txtMonth').val(month);
    	}
    }
    
    function selectDateTimeByLeftDateInlinePicker(){
    	selectDateTime();
    	$('#btnShow').click();
    }
    
    function setTotalTimeByColumn(columnIndex){
    	var rowCount = $('#tableSchedule tr').length;
    	var sum = 0;
    	var cellValueTemp ="";
    	var cellHours = 0;
 	    var cellMinutes = 0;
 	    //alert(rowCount);
		for(var i=0;i < rowCount;i++){
			var inputControl = $('table#tableSchedule tr:eq('+i+') td').eq(columnIndex).find('input');
			
			if(inputControl.length > 0){
				cellValueTemp = inputControl.val();
				if(!(cellValueTemp == "")){
		    		cellHours = cellHours + parseFloat(cellValueTemp.substring(0,2));
		    		cellMinutes = cellMinutes + parseFloat(cellValueTemp.substring(3,6));
		    	}
			}
			
		}
		cellHours = cellHours + parseInt(cellMinutes/60);
	  	cellMinutes = cellMinutes % 60;
	   	cellHours = (cellHours < 10) ? ("0"+cellHours) : cellHours;
	   	cellMinutes = (cellMinutes < 10) ? ("0"+cellMinutes) : cellMinutes;
	   	sum = cellHours + ":" + cellMinutes;
		return sum;
    }
    
    function setTotalTimeInMonth(rowCount){
    	var sum = 0;
    	var cellValueTemp ="";
    	var cellHours = 0;
 	    var cellMinutes = 0;
		for(var i=0;i < rowCount;i++){
			cellValueTemp = $('table#tblprojectEffortInfro tr:eq('+i+') td').eq(8).find('label').text();
			if(!(cellValueTemp == "")){
	    		cellHours = cellHours + parseFloat(cellValueTemp.substring(0,2));
	    		cellMinutes = cellMinutes + parseFloat(cellValueTemp.substring(3,6));
	    	}
		}
		cellHours = cellHours + parseInt(cellMinutes/60);
	  	cellMinutes = cellMinutes % 60;
	   	cellHours = (cellHours < 10) ? ("0"+cellHours) : cellHours;
	   	cellMinutes = (cellMinutes < 10) ? ("0"+cellMinutes) : cellMinutes;
	   	sum = cellHours + ":" + cellMinutes;
		return sum;
    }
    
    function calculateTotalRow(colIndex, rowIndex){
	    var columnCount = $('table#tableSchedule tr:eq('+rowIndex+') td').length;
	    var sumInRow = 0;
	    var cellHours = 0;
	    var cellMinutes = 0;
	   
	    for(var i=0;i< columnCount;i++){
	    	//alert($('table#tableSchedule tr:eq('+rowIndex+') td').eq(i).find('input').val()== "");
	    	cellValueTemp = $('table#tableSchedule tr:eq('+rowIndex+') td').eq(i).find('input').val();
	    	
	    	if(cellValueTemp!= null && !(cellValueTemp == "")){
	    		cellHours = cellHours + parseFloat(cellValueTemp.substring(0,2));
	    		cellMinutes = cellMinutes + parseFloat(cellValueTemp.substring(3,6));
	    	}
	    }
	   // alert($('table#tableSchedule tr:eq('+rowIndex+') td').eq(6).find('input').val());
	   // alert(cellMinutes);
	    cellHours = cellHours + parseInt(cellMinutes/60);
	    cellMinutes = cellMinutes % 60;
	    cellHours = (cellHours < 10) ? ("0"+cellHours) : cellHours;
	    cellMinutes = (cellMinutes < 10) ? ("0"+cellMinutes) : cellMinutes;
	    sumInRow = cellHours + ":" + cellMinutes;
	    return sumInRow;
	}
    
    
    function checkValdation(field){
    	field.value = chkCode(field.value);
    	var x = field.value;
    	var isValid = true;
    	if(x.length == 0){
    		return isValid;
    	}
    	
    	if(x.length < 5 ||
    			!isNumeric(x.substring(0,2)) ||
    			x.substring(0,2) < 0 ||
    			x.substring(0,2) > 23 ||
    			x.substring(2,3) != ":" ||
    			!isNumeric(x.substring(3,6)) ||
    			x.substring(3,6) < 0 ||
    			x.substring(3,6) > 59 ||
    			(x.substring(0,2) == 0 && x.substring(3,6) == 0))
    	{
    		alert("<bean:message key='Alarm.W1030.error'/>");
    		isValid = false;
    	}
    	
    	if(!isValid){
    		field.value = "";
    		field.focus();
    	}	
    	
    	return isValid;
    	
    }
    
    function isNumeric(n)
    {
        var n2 = n;
        n = parseFloat(n);
        return (n!='NaN' && n2==n);
    }
    
    function beforeDelete() {
		return confirm('<%=deleteMessage%>');
	}
    
    function beforeSave(){
    	return confirm("<bean:message key='Alarm.W1102.notice'/>");
    }
    
    function checkProjectNameChange(selectedRowIndex){
		if( oldProjectNameValues[selectedRowIndex] != rowData['projectName']){
			$('#btnSave').removeAttr('disabled');
			$('#btnExport').attr('disabled', '');
		    $('#btnDelete').attr('disabled', '');
		    isProjectNumberWorkCodeChanged = true;
    }
    else{
       isProjectNumberWorkCodeChanged = false;
       if(!isTimeValueChanged){
         $('#btnSave').attr('disabled', '');
         $('#btnExport').removeAttr('disabled');
         $('#btnDelete').removeAttr('disabled');
       }
		}
	}
    
    function checkWorkNameChange(selectedRowIndex){
	    if( oldWorkNameValues[selectedRowIndex] != rowData['workName']){
	      $('#btnSave').removeAttr('disabled');
	      $('#btnExport').attr('disabled', '');
        $('#btnDelete').attr('disabled', '');
        isProjectNumberWorkCodeChanged = true;
      }
      else{
        isProjectNumberWorkCodeChanged = false;
        if(!isTimeValueChanged){
          $('#btnSave').attr('disabled', '');
          $('#btnExport').removeAttr('disabled');
          $('#btnDelete').removeAttr('disabled');
        }
	   }
    }

</script>

<body>
<div class="mainDiv">
<html:form action="inputtablebtest" styleId="formProjectInfo">
<input type="hidden" name="org.apache.struts.taglib.html.TOKEN"
        value="8f72ef608fb385fd757513ff5fc1b091">
<div class="section1">
    <div class="section1Left">
    		<input type="hidden" id="projectChangeFlag" name="projectChangeFlag" value="false">
    		<html:hidden styleId="showbtnDelete" name="InputTableBForm" property="bShowDelete"/>
            <table width="50%">
              <tr>
                <td><bean:write name="InputTableBForm" property="employerCode" /></td>
                <td><bean:write name="InputTableBForm" property="employerName" /></td>
                <td><bean:write name="InputTableBForm" property="divisionName" /></td>
                <td><bean:write name="InputTableBForm" property="departmentName" /></td>
              </tr>
      </table>
    </div>
<div class="section1Right">
   	<logic:equal name="InputTableBForm" property="bChanged" value="false">
   		<html:submit property="method" styleId="btnSave" styleClass="input" onclick="return beforeSave();" disabled="true"><bean:message key="inputtableb.button.save"/></html:submit>
   	</logic:equal>
   	<logic:equal name="InputTableBForm" property="bChanged" value="true">
   		<html:submit property="method" styleId="btnSave" styleClass="input" onclick="return beforeSave();"><bean:message key="inputtableb.button.save"/></html:submit>
   	</logic:equal>
    </div>
</div>

<div class="sectionError">
	 <html:errors />
</div>

<div class="section2">
	<div class="section2Left">
	   <input type="hidden" id="hiddenDatePick"/>
	   <label class="colorLable"><bean:message key="inputtableb.label.timechosing"/></label>
	   <html:text property="inputYear" style="width:40px;" maxlength="6" styleId="txtYear"></html:text>
	   <label><bean:message key="inputtableb.label.yearchosing"/></label>
	   <html:text property="inputMonth" style="width:30px;" maxlength="2" styleId="txtMonth"></html:text>
	   <label><bean:message key="inputtableb.label.monthchosing"/></label>
	   <img id="datepickButton" src="<c:url value="/img/calendar.gif" />" class="trigger"/>
	   &nbsp;
	   &nbsp;
	   <html:submit property="method" styleId="btnShow" styleClass="input"><bean:message key="inputtableb.button.show"/></html:submit>
    </div>
	<div class="section2Right">
   		<logic:empty name="InputTableBForm" property="projectEffortInfoDTOList">
   			<html:submit property="method" styleId="btnExport" styleClass="input" disabled="true"><bean:message key="inputtableb.button.export"/></html:submit>
         	<html:button property="method" styleClass="input" disabled="true"><bean:message key="inputtableb.button.print"/></html:button>
   		</logic:empty>
   		<logic:notEmpty name="InputTableBForm" property="projectEffortInfoDTOList">
   		 	<html:submit property="method" styleId="btnExport" styleClass="input"><bean:message key="inputtableb.button.export"/></html:submit>
         	<html:button property="method" styleClass="input"><bean:message key="inputtableb.button.print"/></html:button>
   		</logic:notEmpty>
 </div>
</div>

<div class="section3">
	<div>
		<label class="colorLable"><bean:message key="inputtableb.label.hoursbyprojectinfo"/></label>
	</div>
    <div>
    <logic:equal name="InputTableBForm" property="bShowAdd" value="true">
       	<html:submit property="method" styleId="btnAdd" styleClass="input"><bean:message key="inputtableb.button.addproject"/></html:submit>
    </logic:equal>
    <logic:equal name="InputTableBForm" property="bShowAdd" value="false">
       	<html:submit property="method" styleId="btnAdd" styleClass="input" disabled="true"><bean:message key="inputtableb.button.addproject"/></html:submit>
    </logic:equal>
   		<logic:empty name="InputTableBForm" property="projectEffortInfoDTOList">
      		<html:submit property="method" styleId="btnDelete" styleClass="input" disabled="true"><bean:message key="inputtableb.button.deleteproject"/></html:submit>
   		</logic:empty>
   		<logic:notEmpty name="InputTableBForm" property="projectEffortInfoDTOList">
   		 	<logic:equal name="InputTableBForm" property="bShowDelete" value="true">
      		<html:submit styleId="btnDelete" property="method" styleClass="input"><bean:message key="inputtableb.button.deleteproject"/></html:submit>
      		</logic:equal>
      		<logic:equal name="InputTableBForm" property="bShowDelete" value="false">
      		<html:submit property="method" styleId="btnDelete" styleClass="input" disabled="true"><bean:message key="inputtableb.button.deleteproject"/></html:submit>
      		</logic:equal>
   		</logic:notEmpty>
	</div>

<div id="div-left">
	<div id="div-left-header">
      <table id="tblprojectEffortInfro-header">
          <tr>
            <th style="width: 21px;"><bean:message key="inputtableb.table.column.select"/></th>
            <th style="width: 96px;"><bean:message key="inputtableb.table.column.projectcode"/></th>
            <th style="width: 73px;"><bean:message key="inputtableb.table.column.seri"/></th>
            <th style="width: 53px;"><bean:message key="inputtableb.table.column.projectname"/></th>
            <th style="width: 110px;"><bean:message key="inputtableb.table.column.workcode"/></th>
            <th style="width: 78px;"><bean:message key="inputtableb.table.column.workname"/></th>
            <th style="width: 33px;"><bean:message key="inputtableb.table.column.subtotaltime"/></th> 
          </tr>
      </table>
     </div>
     <div id="div-left-body">
      <table id="tblprojectEffortInfro">
      <col style="width:21px;"/>
      <col style="width:96px;"/>
      <col style="width:26px;"/>
      <col style="width:47px;"/>
      <col style="width:53px;"/>
      <col style="width:63px;"/>
      <col style="width:47px;"/>
      <col style="width:78px;"/>
      <col style="width:33px;"/>
          <logic:iterate id="projectEffortInfoDTOListObj" name="InputTableBForm"
			property="projectEffortInfoDTOList">
			<tr>
				<logic:equal name="projectEffortInfoDTOListObj" property="bDisable" value="false">
					<logic:equal name="projectEffortInfoDTOListObj" property="bAdd" value="false">
						<td><html:checkbox styleClass="case" name="projectEffortInfoDTOListObj" property="select" indexed="true"/></td>
					</logic:equal>
					<logic:equal name="projectEffortInfoDTOListObj" property="bAdd" value="true">
						<td></td>
					</logic:equal>
				</logic:equal>
				<logic:equal name="projectEffortInfoDTOListObj" property="bDisable" value="true">
					<td></td>
				</logic:equal>
				
				<logic:equal name="projectEffortInfoDTOListObj" property="bDisable" value="false">
					<td><html:text style="width:90px;" styleClass="projectCodeCheck" name="projectEffortInfoDTOListObj" property="projectCode" indexed="true" maxlength="6"></html:text></td>
					<!-- <td><label id="seri"><bean:write name='projectEffortInfoDTOListObj' property='seri'/></label></td> -->
					<td><html:text style="width:25px;" styleClass="projectSeriCheck" name="projectEffortInfoDTOListObj" property="seri" indexed="true"></html:text></td>
					<td><input class="inputFind" type="button" value="<bean:message key="screen.button.search"/>" onclick="findProjectCode(this);"></td>
					<td><label id="projectName"><bean:write name='projectEffortInfoDTOListObj' property='projectName'/></label>
						<html:hidden styleId="hiddenProjectName" name="projectEffortInfoDTOListObj" property="projectName" indexed="true"/>
					</td>
					<td ><html:text style="width:60px;" name="projectEffortInfoDTOListObj" property="workCode" indexed="true" onblur="checkWorkCode(this);"></html:text></td>
					<td><input class="inputFind" type="button" value="<bean:message key="screen.button.search"/>" onclick="findWorkCode(this);"></td>
					<td><label id="workName"><bean:write name='projectEffortInfoDTOListObj' property='workName'/></label>
					<html:hidden styleId="hiddenWorkName" name="projectEffortInfoDTOListObj" property="workName" indexed="true"/>
					</td>
					<td><label id="workTime"><bean:write name='projectEffortInfoDTOListObj' property='workTime'/></label></td>
				</logic:equal>
				<logic:equal name="projectEffortInfoDTOListObj" property="bDisable" value="true">
					<td><html:text style="width:90px;" name="projectEffortInfoDTOListObj" property="projectCode" indexed="true" maxlength="8" disabled="true"></html:text></td>
					<td><html:text style="width:25px;" name="projectEffortInfoDTOListObj" property="seri" indexed="true" disabled="true"></html:text></td>
					<td><input class="inputFind" type="button" value="<bean:message key="screen.button.search"/>" disabled="disabled" onclick="showMessage();"></td>
					<td><bean:write name='projectEffortInfoDTOListObj' property='projectName'/></td>
					<td><html:text style="width:60px;" name="projectEffortInfoDTOListObj" property="workCode" indexed="true" disabled="true"></html:text></td>
					<td><input class="inputFind" type="button" value="<bean:message key="screen.button.search"/>" disabled="disabled" onclick="showMessage();"></td>
					<td><bean:write name='projectEffortInfoDTOListObj' property='workName'/></td>
					<td><label id="workTime"><bean:write name='projectEffortInfoDTOListObj' property='workTime'/></label></td>
				</logic:equal>
				
			</tr>
			</logic:iterate>
			
			<c:if test="${fn:length(InputTableBForm.projectEffortInfoDTOList) lt 10}" >
				<c:forEach var="i" begin="1" end="${10 - fn:length(InputTableBForm.projectEffortInfoDTOList)}">
					<tr>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
			            <td></td>
		          	</tr>
				</c:forEach>
			</c:if>
		</table>
		</div>
	<div id="div-left-footer">
		<table id="tblprojectEffortInfro-footer">
		<col style="width:248px;"/>
		<col style="width:190px;"/>
		<col style="width:32px;"/>
			<tr>
			<td style="border-left: none;"></td>
          	<td align="center" bgcolor="#CCFFFF"><bean:message key="inputtableb.table.column.totaltime"/></td>
            <td><label id="totalTimeInMonth"></label></td>
          	</tr>
   	  	</table>
 	</div>
</div>
  
  
<div id="fake-scroll-container">
	<div id="header-container">
		<table id="table-header">
  			<c:if test="${InputTableBForm.dayNumberOfMonth > 0}" >
		  		<tr class="tableRightRowHeader">
					<c:forEach var="i" begin="1" end="${InputTableBForm.dayNumberOfMonth}">
			            <th scope="col"><c:out value="${i}"/></th>
					</c:forEach>
				</tr>
		
				<tr class="tableRightRowHeader">
					<c:forEach var="k" begin="1" end="${InputTableBForm.dayNumberOfMonth}">
						<td align="center"><bean:write name='InputTableBForm' property='dayNameArray[${k-1}]'/></td>
					</c:forEach>
				</tr>
			</c:if>
		</table>
	</div>
	
	<div id="scroll">
		<table id ="tableSchedule">
			<logic:iterate id="projectEffortInfoDTOListObj" name="InputTableBForm"
					property="projectEffortInfoDTOList">
				<tr>
				<c:forEach var="j" begin="0" end="${fn:length(projectEffortInfoDTOListObj.workDayDTOList) - 1}">
				<logic:equal name="projectEffortInfoDTOListObj" property="workDayDTOList[${j}].bHoliday" value="true">
					<td class="holidayHeader" align="center">
				</logic:equal>
				<logic:equal name="projectEffortInfoDTOListObj" property="workDayDTOList[${j}].bHoliday" value="false">
					<td align="center">
				</logic:equal>
				<logic:equal name="InputTableBForm" property="disableDaysList[${j}]" value="true">
		           <html:text style="width:40px;" name="projectEffortInfoDTOListObj"
		           disabled="true" 
		           property="workDayDTOList[${j}].workTime" indexed="true" />
		        </logic:equal>
		        <logic:equal name="InputTableBForm" property="disableDaysList[${j}]" value="false">
		           <html:text style="width:40px;" name="projectEffortInfoDTOListObj" styleClass="cellSchedule"
		           property="workDayDTOList[${j}].workTime" indexed="true" />
		        </logic:equal>
		           </td>
		          </c:forEach>
		          </tr>
			</logic:iterate>
	
			<c:if test="${fn:length(InputTableBForm.projectEffortInfoDTOList) lt 10}" >
						<c:forEach var="i" begin="1" end="${10 - fn:length(InputTableBForm.projectEffortInfoDTOList)}">
				<tr>
					<c:if test="${InputTableBForm.dayNumberOfMonth > 0}" >
						<c:forEach var="i" begin="0" end="${InputTableBForm.dayNumberOfMonth-1}">
						<logic:equal name="InputTableBForm" property="holidayExLineList[${i}]" value="true">
							<td class="holidayHeader" align="center"></td>
						</logic:equal>
						<logic:equal name="InputTableBForm" property="holidayExLineList[${i}]" value="false">
						<td align="center"></td>
						</logic:equal>
						</c:forEach>
					</c:if>
				</tr>
				
			</c:forEach>
			</c:if>
		</table>
	</div>
	<div id="footer-container">
		<table id="table-footer">
			<!-- Total Group by Column -->
			<tr>
					<c:if test="${InputTableBForm.dayNumberOfMonth > 0}" >
						<c:forEach var="i" begin="0" end="${InputTableBForm.dayNumberOfMonth-1}">
						<td align="center"><label></label></td>
						</c:forEach>
					</c:if>
			</tr>
		</table>
	</div>
	
	<div id="y-fake-scroll">
		<div id="y-table-emulator" style="width:40px;">
			&nbsp;
		</div>
	</div>

	<div id="x-fake-scroll">
		<div id="x-table-emulator">
			&nbsp;
		</div>
	</div>
</div>
</div>
</html:form>
</div>
<%@ include file="../dialog/project_code_search.jsp" %>
<%@ include file="../dialog/work_code_search.jsp" %>
</body>
</html>